module top (
    input        clk,
    input        rst_n,
    input  [3:0] key_in,
    output [7:0] led,
    output [7:0] dula,
    output [7:0] wela
);

    wire [7:0] dp;
    wire [6:0] counter_1;  //计数器1
    wire [6:0] counter_2;  //计数器2
    wire [1:0] countdown_flag;  //倒计时状态
    wire [4:0] countdown;  //倒计时
    wire [3:0] counter_1_tens;  //计数器1十位
    wire [3:0] counter_1_units;  //计数器1个位
    wire [3:0] counter_2_tens;  //计数器2十位
    wire [3:0] counter_2_units;  //计数器2个位
    wire [3:0] countdown_tens;  //倒计时十位
    wire [3:0] countdown_units;  //倒计时个位
    assign counter_1_tens  = counter_1 / 10;
    assign counter_1_units = counter_1 % 10;
    assign counter_2_tens  = counter_2 / 10;
    assign counter_2_units = counter_2 % 10;
    assign countdown_tens  = countdown / 10;
    assign countdown_units = countdown % 10;
    key_proc u_key_proc (
        .clk           (clk),
        .rst_n         (rst_n),
        .key_in        (key_in),
        .counter_1     (counter_1),
        .counter_2     (counter_2),
        .countdown_flag(countdown_flag),
        .countdown     (countdown)
    );


    // 实例化LED处理模块
    led_proc led_proc_inst (
        .clk           (clk),
        .rst_n         (rst_n),
        .countdown_flag(countdown_flag),
        .led           (led)
    );

    // 实例化数码管处理模块
    seg_proc u_seg_proc (
        .clk(clk),
        .rst_n(rst_n),
        .seg_number_in({
            countdown_tens,
            countdown_units,
            4'd10,
            counter_1_tens,
            counter_1_units,
            4'd11,
            counter_2_tens,
            counter_2_units
        }),
        .dp(dp),
        .dula(dula),
        .wela(wela)
    );


endmodule
